-- AltarRuins
-- Created by huanghr Mar/4/2016
-- 元素圣坛废墟

-- 初始化
function initAltarRuins(self)
    self.item:removeAllChildren();

    -- 获取夹层迷宫id
    local unrealId = self.gridData.unreal_id;

    local desc = UnrealDungeonM.query(unrealId, "desc");
    local function onClicked(sender, eventType)
        if eventType == ccui.TouchEventType.began then
            if self.gridData.state == GRID_STATE_DISABLE then
                -- 已经失效，不处理
                return;
            end

            -- 更新建筑访问
            self:updateBuildingVisit();

            -- 获取格子位置
            local pos = self.gridData:getPos();

            -- 音效
            AudioM.playFx("ui_open1");

            -- 打开夹层进入界面
            UIMgr.getCurrentScene():removeFormByName("UIUnrealEnter");
            local uiUnrealEnter = UIUnrealEnter.create(pos, unrealId);
            UIMgr.getCurrentScene():addForm(uiUnrealEnter);
        end
    end

    local iconIndex = UnrealDungeonM.query(unrealId, "icon");
    local iconPath = getLevelItemIconPath(iconIndex);
    self.icon = ccui.ImageView:create(iconPath);
    self.icon:setTouchEnabled(true);
    self.icon:addTouchEventListener(onClicked);
    self.item:addChild(self.icon);
end
